##| column: screen-inset-shaded # wide
cameras <- read_sf("C:/CodigoR/screwworm_mountain_tapir/data/cameras.csv")
# Convert to a Spatial Object (sf)
# CRS 4326 is standard WGS84 for Google Earth
cameras_sf <- st_as_sf(cameras, coords = c("Longitude", "Latitude"), crs = 4326)
puntos_500m <- read_sf("C:/CodigoR/screwworm_mountain_tapir/data/shp/puntos_camaras_500m.geojson")
SFF_Otun_Quimbaya <- read_sf("C:/CodigoR/screwworm_mountain_tapir/data/shp/WDPA_WDOECM_Jan2026_Public_303548_shp-polygons.shp")[,5:9]
PNN_Nevados <- read_sf("C:/CodigoR/screwworm_mountain_tapir/data/shp/WDPA_WDOECM_Jan2026_Public_147_shp-polygons.shp")[,5:9]
PR_Ucumari <- read_sf("C:/CodigoR/screwworm_mountain_tapir/data/shp/WDPA_WDOECM_Jan2026_Public_555555791_shp-polygons.shp")[,5:9]
#corine <- read_sf("C:/CodigoR/screwworm_mountain_tapir/data/shp/ECOSISTEMAS_18062025.gpkg") |> st_transform(4326)
# 2. Using the extent of another object
#target_bbox <- st_bbox(puntos_500m) |> st_buffer(dist = 0.5)
#cropped_corine <- st_crop(corine, target_bbox)
# remove corine large from memory
# rm(corine)
croped_corine <- read_sf("C:/CodigoR/screwworm_mountain_tapir/data/shp/corine_cortado.gpkg") |> st_transform(4326)
# get elevation map
# elevation_18 <- rast(get_elev_raster(cameras_sf, z = 12)) #z =1-14
# bb <- st_as_sfc(st_bbox(elevation_17)) # make bounding box
# extract covs using points and add to _sites
# covs_Col_18_sites <- cbind(Col_18_sites, terra::extract(elevation_18, Col_18_sites))
# covs_Col_17_sites <- cbind(Col_17_sites, terra::extract(elevation_17, Col_17_sites))
# get which are in and out
cameras_sf$in_AP = st_intersects(cameras_sf, SFF_Otun_Quimbaya, sparse = FALSE)
# covs_Col_17_sites$in_AP = st_intersects(covs_Col_17_sites, AP_Yasuni, sparse = FALSE)
# make a map
# mapview (cropped_corine, alpha=0.5) +
# mapview (elevation_18, alpha=0.5) +
# mapview (AP_Ucumari, color = "lightgreen", col.regions = "green", alpha = 0.5) +
# mapview (AP_Nevados, color = "lightgreen", col.regions = "green", alpha = 0.5) +
# mapview (AP_Otun, color = "green", col.regions = "green", alpha = 0.5) +
# mapview(puntos_500m)
# mapview (cameras_sf, zcol = "in_AP", col.regions =c("red","blue"), burst = TRUE)
tmap_mode("view")
#> ℹ tmap modes "plot" - "view"
#> ℹ toggle with `tmap::ttm()`
tm_shape(PR_Ucumari) +
tm_polygons(
#fill = "dwelling_value",
col = "green",
fill = "lightgreen",
fill_alpha = 0.5) +
tm_shape(PNN_Nevados) +
tm_polygons(
#fill = "dwelling_value",
col = "green",
#fill = "lightgreen",
fill_alpha = 0.5) +
tm_shape(SFF_Otun_Quimbaya) +
tm_polygons(
#fill = "dwelling_value",
col = "green",
fill = "lightgreen",
fill_alpha = 0.5) +
tm_shape(puntos_500m) +
tm_dots(
size = 0.3,
#lwd = 1,
fill = "red",
col = "black",
fill_alpha = 0.5
) +
tm_basemap("Esri.WorldTopoMap")+# "CartoDB.Voyager")+# "Stadia.StamenTerrain") +
tm_minimap(position = c("left", "top"),
height = 4,
width = 5)